import React from 'react'

import { useDispatch, useSelector } from 'react-redux'

export default function Books () {

    const list = useSelector(state => {
        console.log(state)
        return state.bookReducer
    })
    const dispatch = useDispatch()

    const handlerclick = () => {
        const payload = { books: '浪潮之巅' }
        dispatch({ type: 'add', payload })
    }

    return (
        <div>Books----

            <ul>

                {list.map(item => <li> {item.books}</li>)}
            </ul>

            <button onClick={handlerclick}> 点击添加数据</button>


        </div>
    )
}
